<script lang="ts" setup>
import { isDark } from '@/utils/is'
import { useAppStore } from '@/store/modules/app'
import { useDesign } from '@/hooks/web/useDesign'
import { CACHE_KEY, useCache } from '@/hooks/web/useCache'
import routerSearch from '@/components/RouterSearch/index.vue'

defineOptions({ name: 'APP' })

const { getPrefixCls } = useDesign()
const prefixCls = getPrefixCls('app')
const appStore = useAppStore()
const currentSize = computed(() => appStore.getCurrentSize)
const greyMode = computed(() => appStore.getGreyMode)
const { wsCache } = useCache()

// 根据浏览器当前主题设置系统主题色
const setDefaultTheme = () => {
  let isDarkTheme = wsCache.get(CACHE_KEY.IS_DARK)
  if (isDarkTheme === null) {
    isDarkTheme = isDark()
  }
  appStore.setIsDark(isDarkTheme)
}
setDefaultTheme()

const tofankui = () => {
  window.open("https://txc.qq.com/products/659523");
}
</script>
<template>
  <ConfigGlobal :size="currentSize">
    <RouterView :class="greyMode ? `${prefixCls}-grey-mode` : ''" />
    <routerSearch />
    <div class="fankui" @click="tofankui">
      <span class="font">我要反馈</span>
    </div>
  </ConfigGlobal>
</template>
<style lang="scss">
$prefix-cls: #{$namespace}-app;

.size {
  width: 100%;
  height: 100%;
}

html,
body {
  @extend .size;

  padding: 0 !important;
  margin: 0;
  overflow: hidden;

  #app {
    @extend .size;
  }

  input:disabled::placeholder,
  textarea:disabled::placeholder {
    opacity: 0 !important;
  }

}

.#{$prefix-cls}-grey-mode {
  filter: grayscale(100%);
}

.fankui {
  cursor: pointer;
  position: fixed;
  right: 1%;
  bottom: 1%;
  width: 30px;
  display: flex;
  height: 90px;
  background-color: rgb(64, 158, 255);
  border-radius: 4px;
  box-shadow: 0px 0px 5px rgb(64, 158, 255);
  color: #FFFFFF;
  font-size: 14px;
  z-index: 999999;

  .font {
    width: 20px;
    padding-left: 8px;
    padding-top: 5px;
  }
}
</style>
